package com.example.esdemo.controller;

import com.example.esdemo.entity.EsTestBean;
import com.example.esdemo.entity.PageEntity;
import com.example.esdemo.service.IEsTestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: kaibo
 * @date: 2020/11/24 18:58
 * @GitHub: https://github.com/yuxuelian
 * @qq: 568966289
 * @description:
 */

@RestController
@RequestMapping("es-test")
@Api(tags = "ES测试接口")
public class EsTestController {

    @Autowired
    IEsTestService iEsTestService;

    @PostMapping("save")
    @ApiOperation("保存一个实体")
    public EsTestBean save(EsTestBean esTestBean) {
        return iEsTestService.save(esTestBean);
    }


    @GetMapping("by-id")
    @ApiOperation("查询指定id的数据")
    public EsTestBean findById(@RequestParam("id") String id) {
        return iEsTestService.findById(id);
    }


    @GetMapping("find-all")
    @ApiOperation("查询所有数据")
    public List<EsTestBean> findAll() {
        return iEsTestService.findAll();
    }


    @GetMapping("page-query")
    @ApiOperation("分页查询数据")
    public PageEntity<EsTestBean> pageQuery(@RequestParam("page") int page,
                                            @RequestParam("pageSize") int pageSize) {
        return iEsTestService.pageQuery(page, pageSize);
    }

}
